/**
 * 
 */
package com.taobao.api;

import java.io.File;
import java.net.URL;
import java.util.Map;

import com.taobao.api.model.TaobaoResponse;


/**
 * Http访问接口
 * 
 * 该接口的实现必需保证线程安全
 * 
 * @author sulinchong.pt
 * @author lin.wangl
 * 
 */
public interface UrlFetch {
	/**
	 * 设置连接超时
	 * 
	 * @param milliSecond
	 */
	public void setConnectTimeout(int milliSecond);

	/**
	 * 设置读超时
	 * 
	 * @param milliSecond
	 */
	public void setReadTimeout(int milliSecond);
	
    /**
     * Sets the maximum number of connections allowed.
     *
     * @param maxTotalConnections The maximum number of connections allowed.
     * 
     * @see #DEFAULT_MAX_TOTAL_CONNECTIONS
     */
    public void setMaxTotalConnections(int maxTotalConnections);
    
    /**
     * Sets maximum number of connections per host
     *
     * @param maxHostConnections The maximum.
     * 
     * @see #MAX_HOST_CONNECTIONS
     */
    public void setMaxConnectionsPerHost(int maxHostConnections);
    
    
    public void setKeepAlive(boolean keepAlive);
    
    /**
     * Defines whether stale connection check is to be used. Disabling 
     * stale connection check may result in slight performance improvement 
     * at the risk of getting an I/O error when executing a request over a
     * connection that has been closed at the server side. 
     * 
     * @param value <tt>true</tt> if stale connection check is to be used, 
     *   <tt>false</tt> otherwise.
     */
    public void setStaleCheckingEnabled(boolean value);

	/**
	 * 根据请求参数像服务器发出请求，访问的URL不需要上传文件
	 * 
	 * 
	 * @param payload
	 *            Map<code><</code>String, CharSequence>
	 * @return UrlResponse
	 */
	public TaobaoResponse fetch(URL url, Map<String, CharSequence> payload)
			throws TaobaoApiException;

	/**
	 * 根据请求参数像服务器发出请求，访问URL需要上传文件
	 * 
	 * @param payload
	 *            Map<code><</code>String, CharSequence>
	 * @return UrlResponse
	 */
	public TaobaoResponse fetchWithFile(URL url,
			Map<String, CharSequence> payload, File file)
			throws TaobaoApiException;

}
